<template>
  <div class="app-container">
    <!-- 查询 -->
    <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" v-if="isHeaderDisplay">
      <template slot="search">
        <el-form-item label="关键信息" prop="name">
          <el-input v-model="queryParam.qry_name" placeholder="输入主题/标签"></el-input>
        </el-form-item>
        <el-form-item label="会议类型">
          <el-cascader v-model="meetType" :options="meetTypeList" filterable @change="handleMeetTypeChange" clearable></el-cascader>
        </el-form-item>
        <el-form-item label="周期类型">
          <el-select v-model="queryParam.qry_periodtype" filterable clearable>
            <el-option v-for="item in codeModel.periodtypeList" :key="item.code" :label="item.name" :value="item.code" />
          </el-select>
        </el-form-item>
      </template>
    </tl-list-search>
    <!-- 工具栏 -->
    <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" @exportExcel="doExportExcel" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :isDisplayDeleteBatch="false" :isDisplayExport="false">
      <template slot="left-btn"> </template>
    </tl-list-toolbar>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a
            >项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
        <el-table-column prop="name" label="会议主题" min-width="180px" sortable="custom" sort-by="name" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispmeettypeid" label="会议类型" width="200px" sortable="custom" sort-by="meettypeid" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="place" label="会议地点" width="200px" sortable="custom" sort-by="place" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="advancedays" label="提前通知天数" width="120px" sortable="custom" sort-by="advancedays" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispperiodtype" label="周期类型" width="80px" sortable="custom" sort-by="periodtype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="begintime" label="会议开始时间" width="170px" sortable="custom" sort-by="begintime" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="endtime" label="会议结束时间" width="170px" sortable="custom" sort-by="endtime" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="keywords" label="会议标签" width="180px" sortable="custom" sort-by="keywords" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispstate" label="会议状态" width="100px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="launchusername" label="会议发起人" width="100px" sortable="custom" sort-by="launchusercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="操作" width="110px" v-slot="scope" fixed="right">
          <el-dropdown trigger="hover">
            <el-button type="text" icon="el-icon-s-operation" style="margin-left:10px">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
            <el-dropdown-menu>
              <el-dropdown-item icon="el-icon-edit" @click.native="openEditDialog('editForm', scope.row.id)">编辑</el-dropdown-item>
              <el-dropdown-item icon="el-icon-delete" @click.native="doLimitDelete(scope.row)">删除</el-dropdown-item>
              <el-dropdown-item icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-edit ref="editForm" @refresh="doRefresh"></tl-edit>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
import tlRefMeetType from '../meetTypeManage/refMeetType'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'meetPeroidTask',
  mixins: [mixin_list],
  components: { tlEdit, tlRefMeetType },
  data() {
    return {
      description: '会议周期任务-列表查询',
      urlPrefix: '/meet/peroidTask/',
      url: {
        queryCodeList: '/meet/peroidTask/dataCodeList',
        queryMeetTypeList: '/meet/typeManage/queryTreeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'id',
        sord: 'desc'
      },
      meetType: [],
      meetTypeList: []
    }
  },
  methods: {
    /** 限制删除*/
    doLimitDelete(data) {
      if (data.state === 1) {
        this.$tap.alert('发布的会议不允许删除！', 'warning')
        return
      }
      this.doDelete(data.id)
    },
    /** 批量删除 */
    doLimitDeleteBatch() {
      let isExistPublish = false
      if (this.selectedRowKeys.length <= 0) {
        this.$tap.alert('请选择记录！', 'warning')
        return
      } else {
        for (var index = 0; index < this.selectionRows.length; index++) {
          if (this.selectionRows[index].state === 1) {
            isExistPublish = true
          }
        }
      }
      if (isExistPublish === true) {
        this.$tap.alert('发布的会议不允许删除！请重新选择', 'warning')
        return
      } else {
        this.doDeleteBatch()
      }
    },
    handleMeetTypeChange(value) {
      this.queryParam.qry_meettypeid = value[value.length - 1]
    }
  },
  created() {
    /** 查询树 */
    getAction(this.url.queryMeetTypeList, { isAddRoot: false }).then((res) => {
      if (res.success) {
        let reg = new RegExp('id', 'g') // g代表全部
        this.meetTypeList = JSON.parse(JSON.stringify(res.result.dataList).replace(reg, 'value'))
      }
    })
  }
}
</script>

<style scoped></style>
